package com.maoye.ossp.biz.statement.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.hotent.base.api.query.QueryFilter;
import com.maoye.ossp.biz.brand.service.ISupplierService;
import com.maoye.ossp.biz.statement.entity.BizStatementBillDetail;
import com.maoye.ossp.biz.statement.entity.BizStatementPaymentDetail;
import com.maoye.ossp.biz.statement.entity.BizStatementPospaySaleSupplierError;
import com.maoye.ossp.biz.statement.entity.BizStatementStmCounter;
import com.maoye.ossp.biz.statement.entity.BizStatementStmError;
import com.maoye.ossp.biz.statement.entity.BizStatementStmPrepaid;
import com.maoye.ossp.biz.statement.service.BizStatementPospaySaleSupplierErrorService;
import com.maoye.ossp.biz.statement.service.BizStatementPospaySaleSupplierService;
import com.maoye.ossp.biz.statement.util.BizStatementConstant;
import com.maoye.ossp.common.entity.Page;
import com.maoye.ossp.common.web.BaseController;
import com.maoye.ossp.sys.org.util.UserUtils;
import com.maoye.sc.api.domain.User;
/**
 * 异常专柜对账控制类
 * 
 * @author liangtao
 * 
 */
@Controller
@RequestMapping(value = "/biz/statement/pospaySaleSupplierError/")
public class BizStatementPospaySaleSupplierErrorController extends
		BaseController {
	@Resource
	private BizStatementPospaySaleSupplierErrorService bizStatementPospaySaleSupplierErrorService;
	
	@Resource
	private BizStatementPospaySaleSupplierService bizStatementPospaySaleSupplierService;
	
	@RequestMapping(value = "save")
	public String save(BizStatementPospaySaleSupplierError bizStatementPospaySaleSupplierError,RedirectAttributes redirectAttributes,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		Long id = idGenerator.getUId();
		bizStatementPospaySaleSupplierError.setId(id);
		bizStatementPospaySaleSupplierErrorService.create(bizStatementPospaySaleSupplierError);
		Map map=new HashMap();
		map.put("shopNo",bizStatementPospaySaleSupplierError.getShopNo());
		map.put("saleDate",bizStatementPospaySaleSupplierError.getSaleDate());
		map.put("barCode",bizStatementPospaySaleSupplierError.getBarCode());
		map.put("chkFlag","02" );
		map.put("id",id);
		bizStatementPospaySaleSupplierService.confirmChked(map);
		addMessage(redirectAttributes, "确认异常成功");
		return "redirect:/biz/statement/pospaySaleSupplier/list?navId=13430000000000003";
	}
	
	@RequestMapping(value="getErrorlist")
	public String getErrorlist(BizStatementPospaySaleSupplierError bizStatementPospaySaleSupplierError,RedirectAttributes redirectAttributes,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		QueryFilter queryFilter = getQuerFilter(request, bizStatementPospaySaleSupplierError);
		Page<BizStatementPospaySaleSupplierError> page = (Page<BizStatementPospaySaleSupplierError>) bizStatementPospaySaleSupplierErrorService
				.find(queryFilter);
		model.addAttribute("page", page);
		return "/biz/statement/statementPospaySaleSupplierError/list";
			
	}
	@RequestMapping(value="view")
	public String view(BizStatementPospaySaleSupplierError bizStatementPospaySaleSupplierError,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		String id =request.getParameter("id");
		bizStatementPospaySaleSupplierError=bizStatementPospaySaleSupplierErrorService.get(id);
		model.addAttribute("bizStatementPospaySaleSupplierError",bizStatementPospaySaleSupplierError);
		return "/biz/statement/statementPospaySaleSupplierError/view";
			
	}
	
	@RequestMapping(value="approvalView")
	public String approvalView(BizStatementPospaySaleSupplierError bizStatementPospaySaleSupplierError,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		String id =request.getParameter("id");
		bizStatementPospaySaleSupplierError=bizStatementPospaySaleSupplierErrorService.get(id);
		model.addAttribute("bizStatementPospaySaleSupplierError",bizStatementPospaySaleSupplierError);
		return "/biz/statement/statementPospaySaleSupplierError/approvalView";
			
	}
	
	@RequestMapping(value="approval")
	public String approval(BizStatementPospaySaleSupplierError bizStatementPospaySaleSupplierError,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		//0驳回 1通过
		bizStatementPospaySaleSupplierErrorService.approval(bizStatementPospaySaleSupplierError);
		return resultPage(SUCCESS, model, request);		
	}
}
